/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.st.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.st.entity.StCheckStandard;
import com.jeesite.modules.st.service.StCheckStandardService;

/**
 * 物料检验标准Controller
 * @author HOHD
 * @version 2020-12-16
 */
@Controller
@RequestMapping(value = "${adminPath}/st/stCheckStandard")
public class StCheckStandardController extends BaseController {

	@Autowired
	private StCheckStandardService stCheckStandardService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public StCheckStandard get(String id, boolean isNewRecord) {
		return stCheckStandardService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("st:stCheckStandard:view")
	@RequestMapping(value = {"list", ""})
	public String list(StCheckStandard stCheckStandard, Model model) {
		model.addAttribute("stCheckStandard", stCheckStandard);
		return "modules/st/stCheckStandardList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("st:stCheckStandard:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<StCheckStandard> listData(StCheckStandard stCheckStandard, HttpServletRequest request, HttpServletResponse response) {
		stCheckStandard.setPage(new Page<>(request, response));
		Page<StCheckStandard> page = stCheckStandardService.findPage(stCheckStandard);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("st:stCheckStandard:view")
	@RequestMapping(value = "form")
	public String form(StCheckStandard stCheckStandard, Model model) {
		model.addAttribute("stCheckStandard", stCheckStandard);
		return "modules/st/stCheckStandardForm";
	}

	/**
	 * 保存数据
	 */
	@RequiresPermissions("st:stCheckStandard:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated StCheckStandard stCheckStandard) {
		stCheckStandardService.save(stCheckStandard);
		return renderResult(Global.TRUE, text("保存物料检验标准成功！"));
	}
	
	/**
	 * 删除数据
	 */
	@RequiresPermissions("st:stCheckStandard:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(StCheckStandard stCheckStandard) {
		stCheckStandardService.delete(stCheckStandard);
		return renderResult(Global.TRUE, text("删除物料检验标准成功！"));
	}
	
}